package com.gzy.cs3.mapper;

import com.gzy.cs3.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Delete;
import java.util.List;

@Mapper
public interface UserMapper {

    @Select("SELECT id, name, age FROM users")

    List<User> getAllUsers();

    @Select("SELECT id, name, age FROM users WHERE id = #{id}")
    User getUserById(int id);

    @Insert("INSERT INTO users (name, age) VALUES (#{name}, #{age})")
    void insertUser(User user);

    @Update("UPDATE users SET name = #{name}, age = #{age} WHERE id = #{id}")
    void updateUser(User user);

    @Delete("DELETE FROM users WHERE id = #{id}")
    void deleteUser(int id);
}
//package com.gzy.cs3.mapper;
//
//        import com.gzy.cs3.model.User;
//        import org.apache.ibatis.annotations.Mapper;
//        import java.util.List;
//
//@Mapper
//public interface UserMapper {
//
//    List<User> getAllUsers();
//
//    User getUserById(int id);
//
//    void insertUser(User user);
//
//    void updateUser(User user);
//
//    void deleteUser(int id);
//
//}
